<template>
  <div class="container">
    <el-form :model="searchList" ref="searchList">
      <el-row :gutter="20">
        <el-col :span="5" :offset="0">
          <el-form-item label="">
            <el-input v-model="searchList.project_name" placeholder="项目名称" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="5" :offset="0">
          <el-form-item label="">
            <el-date-picker v-model="searchList.create_time" type="date" value-format="yyyy-MM-dd" placeholder="建成时间"
              :clearable="true" class="wid">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="5" :offset="0">
          <el-form-item label="">
            <el-select v-model="searchList.project_model" value-key="project_model" placeholder="建设模式" clearable>
              <el-option v-for="item in d_buildType" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="9" :offset="0">
          <div class="right">
            <el-button type="primary" size="medium" @click="search" :loading="loading">查询</el-button>
          </div>
        </el-col>
      </el-row>
    </el-form>
    <div>共 {{titleData.project}}
      个项目，申请金额合计：{{titleData.apply_amount?titleData.apply_amount.toFixed(4):'0.0000'}}万元
    </div>
    <el-table :data="tableData" border stripe :height="offsetHeight" v-loading="loading">
      <el-table-column type="index" label="序号" width="50" align="center">
      </el-table-column>
      <el-table-column label="项目状态" width="105" align="center">
        <template slot-scope="{row}">
          <el-button type="danger" size="mini" v-if="row.check_status=='2'" @click="rejection(row.id)">
            驳回原因
          </el-button>
          <el-tag type="success" size="medium" v-else>录入中</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="project_name" label="项目类型" width="80" align="center">
        <template slot-scope="{row}" v-if="row.copy_status">
          <el-tag type="success" size="medium" v-if="row.copy_status ==='0'">无变化</el-tag>
          <el-tag type="warning" size="medium" v-else-if="row.copy_status ==='1'">有变化</el-tag>
          <el-tag type="primary" size="medium" v-else>新增</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="project_name" label="项目名称" min-width="300" align="center">
      </el-table-column>
      <el-table-column prop="amount" label="总建设投资金额" width="100" align="center">
      </el-table-column>
      <el-table-column label="建设模式" width="100" align="center">
        <template slot-scope="{row}">
          {{row.project_model | f_buildType}}
        </template>
      </el-table-column>
      <el-table-column label="建成时间" width="100" align="center">
        <template slot-scope="{row}">
          {{$util.formatDate(row.create_time)}}
        </template>
      </el-table-column>
      <el-table-column prop="maintenance_amount" label="以往运维资金" width="100" align="center">
      </el-table-column>
      <el-table-column prop="service_pre_amount_sum" label="申请金额" width="100" align="center">
      </el-table-column>
      <el-table-column label="操作" width="300" fixed="right" align="center">
        <template slot-scope="{row}">
          <el-button-group>
            <el-button type="primary" size="mini" @click="projectInfo(row.id)">项目信息</el-button>
            <el-button type="primary" size="mini" @click="contractInfo(row)">合同信息</el-button>
            <el-button type="success" size="mini" @click="advice(row)">审核意见</el-button>
          </el-button-group>
        </template>
      </el-table-column>
    </el-table>
    <!-- 项目驳回信息 -->
    <el-drawer title="项目信息" :visible.sync="rejectShow" size="40%" center :destroy-on-close="true"
      :wrapperClosable="false">
      <reject-item :reject-params="rejectParams"></reject-item>
      <div class="center">
        <el-button type="danger" @click="rejectShow = false">关闭</el-button>
      </div>
    </el-drawer>
    <!-- 项目信息 -->
    <el-drawer title="项目信息" :visible.sync="projectShow" size="70%" center :destroy-on-close="true"
      :wrapperClosable="false">
      <project-item :project-params="projectParams" :switch="this.switch" @cancel="cancel" @init="init"></project-item>
    </el-drawer>
    <!-- 项目审核信息 -->
    <el-drawer title="项目审核信息" :visible.sync="verifyShow" size="50%" center :destroy-on-close="true"
      :wrapperClosable="false">
      <div class="container">
        <verify :verify-params="verifyParams" @cancel="cancel" @init="init"></verify>
      </div>
    </el-drawer>

  </div>
</template>
<script>
import ProjectItem from '@/components/Project'
import RejectItem from '@/components/Reject'
import Verify from './components/verify'
import { d_buildType } from '@/utils/dicts.js'
import { f_buildType } from '@/utils/filters.js'
export default {
  name: 'UnitNoFinish',
  components: {
    ProjectItem, Verify, RejectItem
  },
  props: {
    switch: {
      type: Boolean,
      default: () => {
        return false
      }
    },
    status: {
      type: String,
      default: () => {
        return ''
      }
    },
  },
  data () {
    return {
      offsetHeight: document.documentElement.clientHeight - 300,
      searchList: {},
      loading: false,
      loading: false,
      tableData: [],
      titleData: {},
      rejectShow: false,
      rejectParams: {},
      projectShow: false,
      projectParams: {},
      d_buildType: d_buildType,
      verifyShow: false,
      verifyParams: {}
    }
  },
  created () {

  },
  mounted () {
    this.init()
  },
  methods: {
    async init () {
      const res = await this.$http('findWholeList', {
        status: this.status
      })
      this.titleData = res
      this.loading = true
      const res1 = await this.$http('inputProjectList', {
        del_flag: '0',
        status: this.status,
        menu_level: '1',
        ...this.searchList
      })
      this.tableData = res1
      this.loading = false
    },
    search () {
      this.loading = true
      this.init()
      this.loading = false
    },
    cancel () {
      this.projectShow = false
      this.projectParams = {}
      this.verifyShow = false
      this.verifyParams = {}
    },
    rejection (id) {
      this.rejectShow = true
      this.rejectParams = {
        id: id,
        status: '2',
      }
    },
    projectInfo (pid) {
      this.projectShow = true
      this.projectParams = {
        pid: pid,
      }
    },
    contractInfo (item) {
      sessionStorage.setItem("inputInfo",
        JSON.stringify({
          switch: this.switch,
          pid: item.id,
          pcode: item.project_code,
          pname: item.project_name,
          path: 'noFinish'
        })
      );
      this.$router.push({
        path: './unit/contract',
      })
    },
    advice (item) {
      this.verifyParams = {
        id: item.id,
        status: item.status,
        apply_batch: item.apply_batch,
        internal_code_log: item.internal_code_log
      }
      this.verifyShow = true
    },
  },
  computed: {

  },
  filters: {
    f_buildType: f_buildType
  }
}
</script>
<style scoped>
</style>
